import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import Layout from '../views/Layout/Layout.vue'
import Login from '../views/Login/Login.vue'
// 异步导入
const Goods = ()=>import('../views/Goods/Goods.vue')
const Params = ()=>import('../views/Params/Params.vue')
const ParamsPacking = ()=>import('../views/Params/paramsInfo/ParamsPacking.vue')
const Advert = ()=>import('../views/Advert/Advert.vue')
const Order = ()=>import('../views/Order/Order.vue')
const OrderList = ()=>import('../views/Order/OrderList/OrderList.vue')
const OrderBack = ()=>import('../views/Order/OrderBack/OrderBack.vue')
// 子级路由
const AddGoods = ()=>import('../views/Goods/AddGoods.vue')
Vue.use(VueRouter)
const routes = [
  {
    path:'',
    component:Layout,
    // 路由元信息：用于识别用户身份
    meta:{
      isLogin:true
    },
    children:[
      {
        path:'/',
        name:'Home',
        component:Home
      },
      {
        path:'/params',
        name:'Params',
        component:Params,
        redirect:'/params/paramsPacking',
        children:[
          {
            // 子级路由中不用写'/'
            path:'paramsPacking',
            name:"ParamsPacking",
            component:ParamsPacking
          }
        ]
      },
      {
        path:'/advert',
        name:'Advert',
        component:Advert
      },
      {
        path:'/goods',
        name:'Goods',
        component:Goods
      },
      {
        path:'/add-goods',
        name:'AddGoods',
        component:AddGoods
      },
      {
        path:'/order',
        name:'Order',
        component:Order,
        redirect:'/order/order-list',
        children:[
          {
            path:'order-list',
            component:OrderList
          },
          {
            path:'order-back',
            component:OrderBack
          },
        ]
      },
    ]
  },
  {
    path:'/login',
    name:'Login',
    component:Login
  }
]
const router = new VueRouter({
  routes,
  })

  export default router